<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}
        #l-map{height:100%;width:100%;}
    </style>
	<link rel="stylesheet" href="__PUBLIC__/Home/SaleManager/css/stylesheets/index.css">
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=HKRrGdAa4B8C215lGmGk9GscFH0BCZ27"></script>
    <script src="__JS__/zepto.min.js"></script>
    <link href="__CSS__/weui.min.css" rel="stylesheet">
    <script src="__PUBLIC__/Home/js/jquery-1.8.0.min.js"></script>
    <title>区域诊所分布地图</title>
</head>
<body>
 <header class = "all_header">
      <a class = "h_back h_back_1" href="javascript:void(0)"><img src="__PUBLIC__/Home/SaleManager/images/back_icon.png" alt=""></a>
      <span class = "h_title">区域诊所</span>
      <a class = "h_add" href="javascript:void(0)"></a>
    </header>
<div id="l-map"></div>
</body>
</html>
<script type="text/javascript">

	//获取经纬度（调客户端触发函数）
	var locationTime = setTimeout(checkLocation, 100);
        function checkLocation() {
            var checkKey ='地图#{$uuid}';
            if (checkKey) {
                window.BSFWebView.showInfoFromJs(checkKey);
            }
        }
   
        var mapLat=116.404;
        var maLng = 39.915;     
      //ajax定时
    	var getAdd = setInterval("getAddress()",1000);//1000为1秒钟
    	function getAddress(){  
    		var uid="map{$uuid}";
            $.ajax({  
                url:"/Home/Saleman/Public/getLatLngForSaleMap",  
                type:"get",  
                async: false,
                cache: false,
               	data:{'uid':uid},
              	dataType:"json",
                success: function (returndata) {
                		if(returndata.code==1){
                			maLng=returndata.data.longitude;
                			mapLat=returndata.data.latitude;
                			clearInterval(getAdd);
                		}
                },
                error: function (returndata) {
                    alert(returndata);
                }
           	 }) 
        } 
      
    // 百度地图API功能
    var map = new BMap.Map("l-map");
    map.centerAndZoom(new BMap.Point(mapLat, maLng), 14);
    var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});// 左上角，添加比例尺
    var top_left_navigation = new BMap.NavigationControl();  //左上角，添加默认缩放平移控件
    var top_right_navigation = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}); //右上角，仅包含平移和缩放按钮
    map.addControl(top_left_control);
    map.addControl(top_left_navigation);
    map.addControl(top_right_navigation);

    var position = {$positions};
    // 编写自定义函数,创建标注

    function addMarker(point){
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
    }
    $.each( position ,function(index,pos){
        var point = new BMap.Point(pos.lng,pos.lat);
        console.log(point);
        addMarker(point);
    });

</script>
<script src = "__PUBLIC__/Home/SaleManager/js/index.js"></script>
<script src = "__SaleManager__/js/androidback.js"></script>